<template>
  <div class='search'>
    <f-form ref='form' :action='api.formula' :form-key='this.formItem.formulaId'>
      <f-form-item label='分类' name='formulaType' :required='true' type='select' data-type='number' :data='api.formula.formulaType' :value='formItem.formulaType' />
      <!--   <f-form-item label="机构" type="select" name="organizationId" :value="formItem.organizationId" :data="api.organization.list" valueKey="organizationId" label-key="organizationName" :required="true" @change="organizationChange"/>
         <f-form-item label="公司" ref="company" type="select" name="companyId" :value="formItem.companyId" :data="api.company.list" valueKey="companyId" label-key="companyName" :required="true" :autoLoad="false"/>-->
      <f-form-item label='标题' name='formulaTitle' :required='true' :value='formItem.formulaTitle' />
      <f-form-item label='公式元素' type='other'>
        <a-tag color='pink'>
          销售单价
        </a-tag>
        <a-tag color='red'>
          成本价
        </a-tag>
        <a-tag color='blue'>
          票折价
        </a-tag>
        <a-tag color='orange'>
          数量
        </a-tag>
        <a-tag color='blue'>
          部门结算价
        </a-tag>
        <a-tag color='blue'>
          部门标准
        </a-tag>
        <a-tag color='cyan'>
          部门结算费用
        </a-tag>
        <a-tag color='pink'>
          商务经理结算价
        </a-tag>
        <a-tag color='pink'>
          片区服务商结算价
        </a-tag>
        <a-tag color='pink'>
          片区商务总监结算价
        </a-tag>
        <a-tag color='pink'>
          商务总负责人结算价
        </a-tag>
        <a-tag color='green'>
          供货方高开价
        </a-tag>
        <a-tag color='green'>
          成本金额
        </a-tag>
        <a-tag color='cyan'>
          应结金额
        </a-tag>
        <a-tag color='blue'>
          应结金额2
        </a-tag>
        <a-tag color='purple'>
          供方应返
        </a-tag>

        <a-tag color='green'>
          销售金额
        </a-tag>
        <a-tag color='cyan'>
          供货方高开税金
        </a-tag>
        <a-tag color='blue'>
          供货方资保金费率
        </a-tag>
        <a-tag color='purple'>
          供货方结算费率
        </a-tag>
        <a-tag color='orange'>
          结算高开税金费率
        </a-tag>
        <a-tag color='green'>
          销售结算费率
        </a-tag>
        <a-tag color='green'>
          渠道商标准
        </a-tag>
        <a-tag color='green'>
          商务经理标准
        </a-tag>
        <a-tag color='green'>
          片区服务商标准
        </a-tag>
        <a-tag color='green'>
          片区商务总监标准
        </a-tag>
        <a-tag color='green'>
          商务总负责人标准
        </a-tag>
        <a-tag color='cyan'>
          保证金费率
        </a-tag>
        <a-tag color='green'>
          渠道商结算金额
        </a-tag>
        <a-tag color='green'>
          商务经理结算金额
        </a-tag>
        <a-tag color='green'>
          片区服务商结算金额
        </a-tag>
        <a-tag color='purple'>
          片区商务总监结算金额
        </a-tag>
        <a-tag color='cyan'>
          商务总负责人结算金额
        </a-tag>
        <a-tag color='cyan'>
          支付开票税金
        </a-tag>
        <a-tag color='cyan'>
          税收利润
        </a-tag>
        <a-tag color='cyan'>
          产品利润
        </a-tag>
        <a-tag color='cyan'>
          边际利润
        </a-tag>
      </f-form-item>

      <f-form-item label='公式内容' name='formulaContent' :value='formItem.formulaContent' :required='true' />
      <f-form-item label='备注' name='remark' :value='formItem.remark' />
    </f-form>
  </div>
</template>
<script>
import api from "./js/api"

export default {
  name: "formulaForm",
  props: {},
  data() {
    return {
      refs: this.$refs,
      api: Object.assign(api, this.api),
      isAdd: true,//是否是添加模式
      companyAutoLoad: false,
      loaded: false,//是否加载完成
      formItem: this.getFormItem()
    }
  },
  methods: {
    getFormItem() {
      return {
        formulaId: "",
        formulaTitle: "",
        formulaType: null,
        formulaContent: "",
        remark: ""
      }
    },
    //表单赋值
    setData(data) {
      this.$refs.form.resetFields()
      this.formItem = this.getFormItem()
      if (data && data.formulaId) {
        let params = {
          formulaId: data.formulaId
        }
        this.refs["form"].getDetails(params, (data) => {
          // this.$refs['company'].initData()
          this.formItem = data
          this.loaded = true
        })
        this.isAdd = false
      } else {
        this.loaded = true
      }
    },
    organizationChange(value) {
      this.$refs["company"].initData({ organizationId: value })
    },
    //提交表单
    handleSubmit(callback) {
      this.$refs.form.submit({}, callback)
    }
  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
